<template>
	<view class="home">
		<view class="chat-messages-body">
			<view class="button-box-wrapper">
				<view v-if="blockAuthDetail.goodsRelease.right" class="button-box" @click="go('/itemsReleaseApplication/history/history?userType=' + blockAuthDetail.goodsRelease.primeAuth)">
					<i v-if="pendingData.goodsRelease > 0" class="tip"></i>
					<view class="icon-img home-luggage" style=""></view>
					<view class="text">物品放行</view>
				</view>
				<view v-if="blockAuthDetail.accessCard.right" class="button-box" @click="go('/accessCardApplication/history/history?userType=' + blockAuthDetail.goodsRelease.primeAuth)">
					<i v-if="pendingData.accessCard > 0" class="tip"></i>
					<view class="icon-img home-access" style=""></view>
					<view class="text">门禁卡</view>
				</view>
				<view v-if="blockAuthDetail.airCondition.right" class="button-box" @click="go('/whiteCardApplication/applicationHistory/applicationHistory?userType=' + blockAuthDetail.goodsRelease.primeAuth)">
					<i v-if="pendingData.whiteCard > 0" class="tip"></i>
					<view class="icon-img home-whiteCard" style=""></view>
					<view class="text">白卡</view>
				</view>
				<view v-if="blockAuthDetail.parkingCard.right" class="button-box" @click="go('/parkingCardApplication/history/history?userType=' + blockAuthDetail.goodsRelease.primeAuth)">
					<i v-if="pendingData.parkingCard > 0" class="tip"></i>
					<view class="icon-img home-parking" style=""></view>
					<view class="text">停车位</view>
				</view>
				<view v-if="blockAuthDetail.airCondition.right" class="button-box" @click="go('/airConditionApplication/history/history?userType=' + blockAuthDetail.airCondition.primeAuth)">
					<i v-if="pendingData.airCondition > 0" class="tip"></i>
					<view class="icon-img home-condition" style=""></view>
					<view class="text">空调加时</view>
				</view>
				<view v-if="blockAuthDetail.conferenceRoom.right" class="button-box" @click="go('/conferenceRoom/appointmentRecord/appointmentRecord?userType=' + blockAuthDetail.conferenceRoom.primeAuth)">
					<i v-if="pendingData.conferenceRoom > 0" class="tip"></i>
					<view class="icon-img home-conference" style=""></view>
					<view class="text">会议室</view>
				</view>
				<view v-if="blockAuthDetail.repair.right || blockAuthDetail.invoice.finanCommRight" class="button-box" @click="go('/repair/history/history?userType=' + blockAuthDetail.repair.primeAuth)">
					<i v-if="pendingData.repair > 0" class="tip"></i>
					<view class="icon-img home-repair" style=""></view>
					<view class="text">维修</view>
				</view>
				<view v-if="blockAuthDetail.decoration.right" class="button-box" @click="go('/decorationConstruction/history/history?userType=' + blockAuthDetail.decoration.primeAuth)">
					<i v-if="pendingData.decoration > 0" class="tip"></i>
					<view class="icon-img home-decoration" style=""></view>
					<view class="text">装修</view>
				</view>
				<view v-if="blockAuthDetail.invoice.right" class="button-box" @click="go('/invoiceApplication/history/history?userType=' + blockAuthDetail.invoice.primeAuth)">
					<i v-if="pendingData.invoice > 0" class="tip"></i>
					<view class="icon-img home-invoice" style=""></view>
					<view class="text">发票</view>
				</view>
				<view v-if="blockAuthDetail.costService.right" class="button-box" @click="go('/chargedServiceApplication/history/history?userType=' + blockAuthDetail.costService.primeAuth)">
					<i v-if="pendingData.costService > 0" class="tip"></i>
					<view class="icon-img home-chargeService" style=""></view>
					<view class="text">收费服务</view>
				</view>
				<view v-if="blockAuthDetail.goodsBorrow.right" class="button-box" @click="go('/rentItemsApplication/history/history?userType=' + blockAuthDetail.goodsBorrow.primeAuth)">
					<i v-if="pendingData.goodsBorrow > 0" class="tip"></i>
					<view class="icon-img home-borrow" style=""></view>
					<view class="text">物品借用</view>
				</view>
				<view v-if="blockAuthDetail.knotCommission.right" class="button-box" @click="go('/knotCommission/history/history?userType=' + blockAuthDetail.knotCommission.primeAuth)">
					<i v-if="pendingData.knotCommission > 0" class="tip"></i>
					<view class="icon-img home-knotCommission" style=""></view>
					<view class="text">中介结佣</view>
				</view>
				<view v-if="blockAuthDetail.deliverHouse.right || blockAuthDetail.renewal.contractCommRight" class="button-box" @click="go('/receiveHouse/history/history?userType=' + blockAuthDetail.deliverHouse.primeAuth)">
					<i v-if="pendingData.deliverHouse > 0" class="tip"></i>
					<view class="icon-img home-receive" style=""></view>
					<view class="text">交房</view>
				</view>
				<view v-if="blockAuthDetail.renewal.right" class="button-box" @click="go('/renewHouse/history/history?userType=' + blockAuthDetail.renewal.primeAuth)">
					<i v-if="pendingData.renewal > 0" class="tip"></i>
					<view class="icon-img home-renewHouse" style=""></view>
					<view class="text">续租</view>
				</view>
				<view v-if="blockAuthDetail.exchangeRent.right" class="button-box" @click="go('/exchangeRent/history/history?userType=' + blockAuthDetail.exchangeRent.primeAuth)">
					<i v-if="pendingData.exchangeRent > 0" class="tip"></i>
					<view class="icon-img home-exchange" style=""></view>
					<view class="text">退换租</view>
				</view>
				<view v-if="blockAuthDetail.invoice.finanCommRight" class="button-box" @click="go('/onlinePay/history/history?userType=' + blockAuthDetail.invoice.primeAuth)">
					<i v-if="pendingData.onlinePay > 0" class="tip"></i>
					<view class="icon-img home-onlinePay" style=""></view>
					<view class="text">缴费通知</view>
				</view>
				<view class="button-box" style="opacity: 0"> </view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		appMixin
	} from "../../util/reuse"
	import {
		d_uniShowToast,
		CURRENT_USER_KEY,
		ROUTER_OBJ,
		SHORT_TOAST_DURATION,
		TOAST_DURATION,
		uniNavigate
	} from "../../util/misc"
	import {
		uniHideLoading
	} from "../../util/commonFuncs"
	import {
		authRouterGuard,
		homeInitLocation,
		uniRedirect,
		uniSetToken,
		uniGetStorageSync
	} from '../../util/funcs';
	import {
		uniRequestP,
		tokenRequestP
	} from '../../util/network.js'

	export default {
		mixins: [appMixin],
		components: {},
		data() {
			return {
				address: {
					province: '',
					city: '',
					district: '',
				},
				swiperlist: [],
				flag:1,
				userInfo:[],
				authTypeDetail:{"operLeader":1,
				                "operMem":1,
								"businessLeader":1,
								"businessMem":1,
								"financeLeader":1,
				                "financeMem":1,
								"engineerLeader":1,
								"engineerMem":1,
								"mappingLeader":1,
								"mappingMem":1,
								"contractLeader":1,
								"contractMem":1,
								"director":1,
				},
				blockAuthDetail:{"goodsRelease":{"right":true,"primeAuth":2},
				                "accessCard":{"right":true,"primeAuth":2},
								"whiteCard":{"right":true,"primeAuth":2},
								"parkingCard":{"right":true,"primeAuth":2},
								"airCondition":{"right":true,"primeAuth":2},
				                "conferenceRoom":{"right":true,"primeAuth":2},
								"repair":{"right":true,"primeAuth":2},
								"decoration":{"right":true,"primeAuth":2},
								"invoice":{"right":true,"primeAuth":2},
								"costService":{"right":true,"primeAuth":2},
								"goodsBorrow":{"right":true,"primeAuth":2},
								"knotCommission":{"right":true,"primeAuth":2},
								"deliverHouse":{"right":true,"primeAuth":2},
								"exchangeRent":{"right":true,"primeAuth":2},
				},
				pendingData:'',
			}
		},

		onLoad: async function() {
			console.log('ceshi',uni.getStorageSync("userRight"))
			this.blockAuthDetail = uni.getStorageSync("userRight")
			// authRouterGuard(this).then(async (res) => {
			// 	this.userInfo = uniGetStorageSync(CURRENT_USER_KEY)
			// 	console.log('ceshi',this.userInfo)
			// })
			
		},
		onShow() {
			this.pendingData = this.$pendingObj.pendingObj
		},

		methods: {
			go(page) {
				// uniNavigate(page)
				//console.log('ceshi',this.$data)
				console.log('asd',this.$store.state.token)
				if (this.$store.state.token) {
				//if (true) {
					uniNavigate(page)
				} else {
					uni.showToast({
						title: "请登录",
						position: 'top',
						icon: 'none',
						duration: TOAST_DURATION
					});
					setTimeout(() => {
						uniRedirect('/login/login');
					}, TOAST_DURATION)
				}
			},
		},
	}
</script>

<style scoped lang="scss">
	@import '../../assets/styles/global';
	.home{
		height: 100%;
		overflow-y: scroll;
	}
	
	.big-header {
		background-image: linear-gradient(180deg, #2667b9 0%, #113e7e 100%);
		padding-top: 20px;
		height: 388rpx;
		z-index: 5; // 要比滑下来的东西高一点
	}

	.swiper {
		background-color: whitesmoke;
		z-index: 1;
		width: 686rpx;
		height: 400rpx;
		border-radius: 15px;
		margin-top: -242rpx;
	}

	.search {
		color: #ffffff;
		display: flex;
		height: 40px;
		line-height: 40px;
		background-color: #487ec4;
		border-radius: 30px;
		padding: 0px 1em;
		flex-wrap: inherit;
		margin-bottom: 30rpx;
	}

	.chat-messages-body {
		position: relative;
		width: 100vw;
		padding: 30rpx 30rpx 0;

		.button-box-wrapper {
			display: flex;
			display: flex;
			justify-content: space-between;
			flex-wrap: wrap;

			.button-box {
				@include center;
				flex-direction: column;
				.icon-img {
					width: 80rpx;
					height: 80rpx;
					@include contain-no-repeat-center;
					margin-bottom: 20rpx;
				}

				.home-luggage {
					background-image: url('../../static/order/home-luggage.png');
				}

				.home-access {
					background-image: url('../../static/order/home-access.png');
				}

				.home-whiteCard {
					background-image: url('../../static/order/home-whiteCard.png');
				}

				.home-parking {
					background-image: url('../../static/order/home-parking.png');
				}

				.home-condition {
					background-image: url('../../static/order/home-condition.png');
				}

				.home-conference {
					background-image: url('../../static/order/home-conference.png');
				}
				
				.home-repair {
					background-image: url('../../static/order/home-repair.png');
				}
				
				.home-decoration {
					background-image: url('../../static/order/home-decoration.png');
				}
				
				.home-invoice {
					background-image: url('../../static/order/home-invoice.png');
				}
				
				.home-chargeService {
					background-image: url('../../static/order/home-chargeService.png');
				}
				
				.home-borrow {
					background-image: url('../../static/order/home-borrow.png');
				}
				
				.home-receive {
					background-image: url('../../static/order/home-receive.png');
				}
				
				.home-renewHouse {
					background-image: url('../../static/order/home-renewHouse.png');
				}
				
				.home-exchange {
					background-image: url('../../static/order/home-exchange.png');
				}
				
				.home-onlinePay {
					background-image: url('../../static/order/home-onlinePay.png');
				}
				
				.home-knotCommission {
					background-image: url('../../static/order/home-knotCommission.png');
				}

				.text {
					height: 48rpx;
					font-family: PingFangSC-Medium;
					font-size: 28rpx;
					color: #323233;
				}
				.jiao, .desc {
					position: relative;
					top:0;
					left: 105rpx;
				}
				.jiao {
					line-height: 18px;
					width: 18px;
					height: 18px;
					// transform: rotate(-50deg);
					border-radius: 50%;
					// -webkit-transform: rotate(-50deg);
					// -moz-transform: rotate(-50deg);
					// -ms-transform: rotate(-50deg);;
					top: -15px;
					right: -4px;
					background-color: #d51414;
					padding:0;
				}
				.desc {
					top: -30rpx;
				}
				width: 210rpx;
				height: 210rpx;
				background-color: #ffffff;
				/*background-color: red;*/
				box-shadow: 0rpx 4rpx 8rpx 0rpx rgba(26, 79, 150, 0.14);
				border-radius: 8rpx;
				border: solid 1rpx #c8c9cc;
				margin-bottom: 30rpx;
			}
		}
	}

	.SelectIcon {
		width: 10px;
		height: 10px;
	}

	.srollView {
		white-space: nowrap;
	}

	.rollViewItem {
		display: inline-block;
	}

	.place {
		font-size: 16px;
		margin-right: 5px;
		max-width: 120px;
		white-space: nowrap;
	}

	.titleMargin {
		margin: 30px 0 20px 15px;
		font-size: 18px;
	}

	.recommendHouse {
		padding: 10px 0;
		border-bottom: 1px solid #f5f6f7;
		display: flex;
	}

	.recommendHouse:nth-child(1) {
		padding-top: 0px;
	}

	.img {
		width: 100%;
	}

	.swiperItems {
		border-radius: 10px;
	}

	.search>icon {
		margin-left: 5px;
		position: relative;
		top: 1px;
	}

	.search>option {
		border: none;
		outline: none;
		background: #487ec4;
	}

	.search>select {
		color: #ffffff;
		padding-left: 1em;
		font-size: 16px;
		border: none;
		outline: none;
		border: 0;
		background: transparent;
	}

	.search>input {
		height: 40px;
		width: 70%;
		margin-left: 5px;
	}

	.search>input::-webkit-input-placeholder {
		color: #ffffff !important;
	}

	.fl {
		float: left;
	}

	.fr {
		float: right;
	}

	.fixed:after {
		content: '';
		display: block;
		clear: both;
	}
	.tip {
		width:10px;
		height:10px;
		line-height:20px;
		font-size:10px;
		color:#fff;
		text-align:center;
		background-color:#f00;
		border-radius:50%;
		margin-top: -15rpx;
		margin-left: 150rpx;
	}
</style>
